﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Wasion.HHU.Services
{
    public interface IWsComm
    {
        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="errinfo">回传错误信息</param>
        /// <returns>大于0表示成功  小于0表示失败</returns>
        int InitCommInfo(ref string errinfo);  


        /// <summary>
        /// 添加指令
        /// </summary>
        /// <param name="aOrder">指令类</param>
        /// <param name="maxovertime">回传该指令的最大等待时间</param>
        /// <param name="errinfo">回传错误信息</param>
        /// <returns>大于0表示成功  小于0表示失败</returns>
        int AddOrder(CommConst.TOrdertype aOrder, ref int maxovertime, ref string errinfo);

        /// <summary>
        /// 启动发指令
        /// </summary>
        /// <param name="aOrder">指令类</param>
        /// <param name="errinfo">回传错误信息</param>
        /// <returns>大于0表示成功  小于0表示失败</returns>
        int StartOrder(CommConst.TOrdertype aOrder, ref string errinfo);

        /// <summary>
        /// 启动监听
        /// </summary>
        /// <param name="aOrder">指令类</param>
        /// <param name="errinfo">回传错误信息</param>
        /// <returns>大于0表示成功  小于0表示失败</returns>
        int StartListen(CommConst.TOrdertype aOrder, ref string errinfo);

        /// <summary>
        /// 对主动上报的发确认 2019-8-19
        /// </summary>
        /// <param name="aOrder"></param>
        /// <param name="errinfo"></param>
        /// <returns></returns>
        int UploadConfirm(CommConst.TOrdertype aOrder, ref string errinfo);



        /// <summary>
        /// 停止发指令
        /// </summary>
        /// <param name="meteridOrcommname">表ID或串口号</param>
        /// <param name="errinfo">回传错误信息</param>
        /// <returns>大于0表示成功  小于0表示失败</returns>
        int StopOrder(string meteridOrcommname, ref string errinfo);


        /// <summary>
        /// 清空指令
        /// </summary>
        /// <param name="meteridOrcommname">表ID或串口号</param>
        /// <param name="errinfo">回传错误信息</param>
        /// <returns>大于0表示成功  小于0表示失败</returns>
        int ClearOrder(string meteridOrcommname, ref string errinfo);



        /// <summary>
        /// 串口通信用于关闭串口，TCP串口用于断开TCP连接
        /// </summary>
        /// <param name="meteridOrcommname">表ID或串口号</param>
        /// <param name="errinfo">回传错误信息</param>
        /// <returns>大于0表示成功  小于0表示失败</returns>
        int CloseComm(string meteridOrcommname, ref string errinfo);

        /// <summary>
        /// 串口通信用于关闭和某个表的通信
        /// </summary>
        /// <param name="commname">串口号</param>
        /// <param name="meterid">表ID</param>
        /// <param name="errinfo">回传错误信息</param>
        /// <returns>大于0表示成功  小于0表示失败</returns>
        int CloseComm(string commname, string meterid, ref string errinfo);


        /// <summary>
        /// 刷新波特率
        /// </summary>
        /// <param name="aComm">串口号</param>
        /// <param name="newBaudRate">新波特率</param>
        /// <param name="errinfo">回传错误信息</param>
        /// <returns>大于0表示成功  小于0表示失败</returns>
        int RefreshBaudRate(string aComm, int newBaudRate, ref string errinfo);
        
    }
}
